Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/messaging/classes/class.messaging.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
0.00 %0.00%
0.00% 0 / 179
 
Messaging
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 15
0.00 %0.00%
0.00% 0 / 179
 public function __construct($userID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 9
 public function sendMessage(&$recipients, $subject, $message, $asEmail = 0, $saveInOutbox = true)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 98
 private function pmAsEmail($userID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function sameNameUsers($userID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function markMessageAsRead($messageID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 public function deleteMessage($messageID, $type)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 public function archiveMessage($messageID, $type)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function getRecipients($RecipientsID, $limit, $breaks)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 20
 public function getOrderByLink($feld)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 public function getUserID()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function getRole()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public function getDB()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 public static function includeMessagingCSSFile()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public static function getAutoSearchJavaScript()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public static function setGlobalVariables()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7


       1                 : <?php                                                                                                                                                                                                                                                                                          
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                                                                  
       3                 : This file is part of eStudy.                                                                                                                                                                                                                                                                   
       4                 : messaging/classes/class.messaging.inc.php                                                                                                                                                                                                                                                      
       5                 : - Modulgruppe:  Messaging                                                                                                                                                                                                                                                                      
       6                 : - Beschreibung: Implementation der Messaging-Funktionen.                                                                                                                                                                                                                                       
       7                 : - Version:      0.2, 21.01.2009                                                                                                                                                                                                                                                                
       8                 : - Autor(en):                                                                                                                                                                                                                                                                                   
       9                 : Alexander Rausch <alexander.rausch@mni.fh-giessen.de> [Refactoring WS 08/09],                                                                                                                                                                                                                  
      10                 : Waldemar Krampetz <waldemar.krampetz@mni.fh-giessen.de>,                                                                                                                                                                                                                                       
      11                 : Dennis Bayer <dennis.bayer@mni.fh-giessen.de><bayer.d@gmx.de>                                                                                                                                                                                                                                  
      12                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                  
      13                 : This program is free software; you can redistribute it and/or                                                                                                                                                                                                                                  
      14                 : modify it under the terms of the GNU General Public License                                                                                                                                                                                                                                    
      15                 : as published by the Free Software Foundation; either version 2                                                                                                                                                                                                                                 
      16                 : of the License, or any later version.                                                                                                                                                                                                                                                          
      17                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                  
      18                 : This program is distributed in the hope that it will be useful,                                                                                                                                                                                                                                
      19                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                                                                 
      20                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                                                                  
      21                 : GNU General Public License for more details.                                                                                                                                                                                                                                                   
      22                 : You should have received a copy of the GNU General Public License                                                                                                                                                                                                                              
      23                 : along with this program; if not, write to the Free Software                                                                                                                                                                                                                                    
      24                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                                                                    
      25                 : +--------------------------------------------------------------------------*/                                                                                                                                                                                                                  
      26                 : /**                                                                                                                                                                                                                                                                                            
      27                 :  * Helpklasse für das Modul Private Nachrichten                                                                                                                                                                                                                                               
      28                 :  * @package eStudy.Messaging                                                                                                                                                                                                                                                                   
      29                 :  * @version 0.1 21.01.2009                                                                                                                                                                                                                                                                     
      30                 :  * @author Waldemar Krampetz <waldemar.krampetz@mni.fh-giessen.de>                                                                                                                                                                                                                             
      31                 :  * @author Dennis Bayer <dennis.bayer@mni.fh-giessen.de><bayer.d@gmx.de>                                                                                                                                                                                                                       
      32                 :  * @author Alexander Rausch <alexander.rausch@mni.fh-giessen.de>                                                                                                                                                                                                                               
      33                 :  */                                                                                                                                                                                                                                                                                            
      34                 :                                                                                                                                                                                                                                                                                                
      35                 : /* Generelle includesfür alle Klassen des Moduls */                                                                                                                                                                                                                                           
      36                 : require_once (PATH_TO_ROOT."common/classes/class.email.inc.php");                                                                                                                                                                                                                              
      37                 : require_once (PATH_TO_ROOT."common/classes/class.bbcode.inc.php");                                                                                                                                                                                                                             
      38                 : require_once (PATH_TO_ROOT."roleplay/classes/class.roleartefacts.inc.php");                                                                                                                                                                                                                    
      39                 :                                                                                                                                                                                                                                                                                                
      40                 : /**                                                                                                                                                                                                                                                                                            
      41                 :  * Diese Klasse ist eine Hilfsklasse für die einzelen Views.                                                                                                                                                                                                                                  
      42                 :  * Sie implementiert verschiedene Methoden die öfters gebraucht werden.                                                                                                                                                                                                                       
      43                 :  *                                                                                                                                                                                                                                                                                             
      44                 :  * @package eStudy.Messaging                                                                                                                                                                                                                                                                   
      45                 :  * @author Waldemar Krampetz <waldemar.krampetz@mni.fh-giessen.de>                                                                                                                                                                                                                             
      46                 :  * @author Dennis Bayer <dennis.bayer@mni.fh-giessen.de><bayer.d@gmx.de>                                                                                                                                                                                                                       
      47                 :  * @version 0.2, 10/02/05                                                                                                                                                                                                                                                                      
      48                 :  */                                                                                                                                                                                                                                                                                            
      49                 : class Messaging {                                                                                                                                                                                                                                                                              
      50                 :     /**                                                                                                                                                                                                                                                                                        
      51                 :      * Beinhaltet UserID des eingelogten Users.                                                                                                                                                                                                                                                
      52                 :      * @var integer $userID                                                                                                                                                                                                                                                                    
      53                 :      */                                                                                                                                                                                                                                                                                        
      54                 :     private $userID;                                                                                                                                                                                                                                                                           
      55                 :                                                                                                                                                                                                                                                                                                
      56                 :     /**                                                                                                                                                                                                                                                                                        
      57                 :      * Rolle des aktuellen Benutzers                                                                                                                                                                                                                                                           
      58                 :      * @var object $role                                                                                                                                                                                                                                                                       
      59                 :      */                                                                                                                                                                                                                                                                                        
      60                 :     private $role;                                                                                                                                                                                                                                                                             
      61                 :                                                                                                                                                                                                                                                                                                
      62                 :     /**                                                                                                                                                                                                                                                                                        
      63                 :      * DB-Access                                                                                                                                                                                                                                                                               
      64                 :      *                                                                                                                                                                                                                                                                                         
      65                 :      * @var object $db                                                                                                                                                                                                                                                                         
      66                 :      */                                                                                                                                                                                                                                                                                        
      67                 :     private $db;                                                                                                                                                                                                                                                                               
      68                 :                                                                                                                                                                                                                                                                                                
      69                 :     /**                                                                                                                                                                                                                                                                                        
      70                 :      * Zend_Translate - Objekt                                                                                                                                                                                                                                                                 
      71                 :      * @var object $translate                                                                                                                                                                                                                                                                  
      72                 :      */                                                                                                                                                                                                                                                                                        
      73                 :     private $translate;                                                                                                                                                                                                                                                                        
      74                 :                                                                                                                                                                                                                                                                                                
      75                 :     /**                                                                                                                                                                                                                                                                                        
      76                 :      * Konstruktor: Stellt die UserID den Methoden zur Verfuegung.                                                                                                                                                                                                                             
      77                 :      * @access public                                                                                                                                                                                                                                                                          
      78                 :      * @param integer $userID Uebergabe der UserID des eingeloggten Users.                                                                                                                                                                                                                     
      79                 :      * @return void                                                                                                                                                                                                                                                                            
      80                 :      */                                                                                                                                                                                                                                                                                        
      81                 :     public function __construct($userID) {                                                                                                                                                                                                                                                     
      82                 :         /* User-ID setzen */                                                                                                                                                                                                                                                                   
      83               0 :         $this->userID = $userID;                                                                                                                                                                                                                                                               
      84                 :                                                                                                                                                                                                                                                                                                
      85                 :         /* DB Access holen */                                                                                                                                                                                                                                                                  
      86               0 :         global $db;                                                                                                                                                                                                                                                                            
      87               0 :         $this->db = $db;                                                                                                                                                                                                                                                                       
      88                 :                                                                                                                                                                                                                                                                                                
      89               0 :         $this->translate = getTranslate("messaging");                                                                                                                                                                                                                                          
      90                 :                                                                                                                                                                                                                                                                                                
      91               0 :         if (empty($_POST)) $_POST["asEmail"] = 1;                                                                                                                                                                                                                                              
      92                 :                                                                                                                                                                                                                                                                                                
      93               0 :         if (isset($_SESSION["roleID"])) {                                                                                                                                                                                                                                                      
      94               0 :             $this->role = new Role($_SESSION["roleID"]);                                                                                                                                                                                                                                       
      95               0 :         }                                                                                                                                                                                                                                                                                      
      96               0 :     }                                                                                                                                                                                                                                                                                          
      97                 :                                                                                                                                                                                                                                                                                                
      98                 :     /**                                                                                                                                                                                                                                                                                        
      99                 :      * Sendet die Nachricht an den angegeben User                                                                                                                                                                                                                                              
     100                 :      * @access public                                                                                                                                                                                                                                                                          
     101                 :      * @param string &$recipients Referenzangabe der Empfaengerliste (Nachname, Vorname...                                                                                                                                                                                                     
     102                 :      * @param string $subject Betreffzeile                                                                                                                                                                                                                                                     
     103                 :      * @param string $message Nachrichtentext                                                                                                                                                                                                                                                  
     104                 :      * @param bool $asEmail Versenden als E-Mail                                                                                                                                                                                                                                               
     105                 :      * @param bool $saveInOutbox Nachricht wird in Outbox gespeichert                                                                                                                                                                                                                          
     106                 :      * @return true falls erfolgreich, andernfalls false                                                                                                                                                                                                                                       
     107                 :      */                                                                                                                                                                                                                                                                                        
     108                 :     public function sendMessage(&$recipients, $subject, $message, $asEmail = 0, $saveInOutbox = true) {                                                                                                                                                                                        
     109               0 :         global $settings;                                                                                                                                                                                                                                                                      
     110               0 :         $success = true;                                                                                                                                                                                                                                                                       
     111               0 :         $allRecipients = explode(";", Data::gpcUnescape($recipients));                                                                                                                                                                                                                         
     112               0 :         $count = count($allRecipients);                                                                                                                                                                                                                                                        
     113                 :         // Leere Elemente ausfiltern                                                                                                                                                                                                                                                           
     114               0 :         for ($i = 0 ; $i < $count ; $i++) {                                                                                                                                                                                                                                                    
     115               0 :             $allRecipients[$i] = trim($allRecipients[$i]);                                                                                                                                                                                                                                     
     116               0 :             if ($allRecipients[$i] == "") unset($allRecipients[$i]);                                                                                                                                                                                                                           
     117               0 :         }                                                                                                                                                                                                                                                                                      
     118                 :         // Doppelte User ausfiltern                                                                                                                                                                                                                                                            
     119               0 :         $allRecipients = array_unique($allRecipients);                                                                                                                                                                                                                                         
     120               0 :         $outboxRecipients = $recipientsSuccess = $recipientsFailed = "";                                                                                                                                                                                                                       
     121               0 :         for ($i = 0 ; $i < $count ; $i++) {                                                                                                                                                                                                                                                    
     122               0 :             if (!isset($allRecipients[$i])) continue;                                                                                                                                                                                                                                          
     123               0 :             $recipientID = -1;                                                                                                                                                                                                                                                                 
     124                 :             //AENDERUNG WEGEN SAMMLUNG DER FEHLENDEN USER; Jeder nicht eindeutige User bekommt nun eine einzelne Fehlermeldung                                                                                                                                                                 
     125               0 :             $shortNamesError = "";                                                                                                                                                                                                                                                             
     126               0 :             $recipient = explode(",", trim($allRecipients[$i]));                                                                                                                                                                                                                               
     127               0 :             if (!isset($recipient[1])) {                                                                                                                                                                                                                                                       
     128               0 :                 $recipientResult = $this->db->get_results("SELECT ID, ShortName, Vorname                                                                                                                                                                                                       
     129                 :                                                    FROM user                                                                                                                                                                                                                                   
     130               0 :                                                    WHERE user.Nachname='".Data::toMysql(trim($recipient[0]), false) ."'");                                                                                                                                                                     
     131               0 :             } elseif (!isset($recipient[2])) {                                                                                                                                                                                                                                                 
     132               0 :                 $recipientResult = $this->db->get_results("SELECT ID, ShortName, Vorname                                                                                                                                                                                                       
     133                 :                                                    FROM user                                                                                                                                                                                                                                   
     134               0 :                                                    WHERE user.Nachname='".Data::toMysql(trim($recipient[0]), false) ."'                                                                                                                                                                        
     135               0 :                                                     AND user.Vorname='".Data::toMysql(trim($recipient[1]), false) ."'");                                                                                                                                                                       
     136               0 :             } else {                                                                                                                                                                                                                                                                           
     137                 :                 $sql = "SELECT ID, Vorname, ShortName                                                                                                                                                                                                                                          
     138                 :                         FROM user                                                                                                                                                                                                                                                              
     139               0 :                         WHERE user.Nachname='".Data::toMysql(trim($recipient[0]), false) ."'                                                                                                                                                                                                   
     140               0 :                         AND user.Vorname='".Data::toMysql(trim($recipient[1]), false) ."'";                                                                                                                                                                                                    
     141               0 :                 $sqlAdd = "";                                                                                                                                                                                                                                                                  
     142                 :                                                                                                                                                                                                                                                                                                
     143                 :                                                                                                                                                                                                                                                                                                
     144                 :                 //Prüfen ob User-ID oder User-Kurzbezeichnung                                                                                                                                                                                                                                 
     145               0 :                 if(is_numeric(trim($recipient[2]))) {                                                                                                                                                                                                                                          
     146               0 :                     $sqlAdd = " AND user.ID='".Data::toMysql(trim($recipient[2]), false) ."'";                                                                                                                                                                                                 
     147               0 :                 }                                                                                                                                                                                                                                                                              
     148                 :                 else {                                                                                                                                                                                                                                                                         
     149               0 :                     $sqlAdd = " AND user.ShortName='".Data::toMysql(trim($recipient[2]), false) ."'";                                                                                                                                                                                          
     150                 :                 }                                                                                                                                                                                                                                                                              
     151               0 :                 $sql .= $sqlAdd;                                                                                                                                                                                                                                                               
     152               0 :                 $recipientResult = $this->db->get_results($sql);                                                                                                                                                                                                                               
     153                 :             }                                                                                                                                                                                                                                                                                  
     154               0 :             $anzahl = $this->db->num_rows;                                                                                                                                                                                                                                                     
     155               0 :             if ($anzahl > 0) {                                                                                                                                                                                                                                                                 
     156               0 :                 foreach($recipientResult as $recipientRow) {                                                                                                                                                                                                                                   
     157               0 :                     $recipientID = $recipientRow->ID;                                                                                                                                                                                                                                          
     158               0 :                     $correctRecipientString = $recipient[0].", ".$recipientRow->Vorname.", ".$recipientRow->ShortName;                                                                                                                                                                         
     159               0 :                     $shortNamesError.= "<a href='#' onclick='javascript:addUserToRecipients(\"".$correctRecipientString."\")'>".$correctRecipientString."</a><br />";                                                                                                                          
     160               0 :                 }                                                                                                                                                                                                                                                                              
     161               0 :             }                                                                                                                                                                                                                                                                                  
     162               0 :             if ($recipientID > 0) $isIgnored = $this->db->get_var("SELECT isIgnored FROM messaging_buddylist WHERE userID=".$recipientID." AND buddyID=".$this->userID);                                                                                                                       
     163               0 :             else $isIgnored = "0";                                                                                                                                                                                                                                                             
     164               0 :             if ($anzahl > 1) {                                                                                                                                                                                                                                                                 
     165               0 :                 $errorMessage = sprintf($this->translate->_("Benutzer nicht eindeutig ermittelbar. Bitte folgende Schreibweise verwenden:<br/><em>Nachname, Vorname, <strong>User-ID oder User-Kennung</strong></em><br/><br/>Verfuegbare Empfaenger:<br /> %1\$s"),$shortNamesError);         
     166               0 :                 Output::errorMessage($errorMessage);                                                                                                                                                                                                                                           
     167               0 :                 $success = false;                                                                                                                                                                                                                                                              
     168               0 :                 $recipientsFailed = $recipientsFailed."; ".trim($allRecipients[$i]);                                                                                                                                                                                                           
     169               0 :             } elseif ($isIgnored == "1") {                                                                                                                                                                                                                                                     
     170               0 :                 $errorMessage = sprintf($this->translate->_("Sie stehen bei %1\$s auf der Ignoreliste."), trim($allRecipients[$i]));                                                                                                                                                           
     171               0 :                 Output::errorMessage($errorMessage);                                                                                                                                                                                                                                           
     172               0 :                 $success = false;                                                                                                                                                                                                                                                              
     173               0 :             } elseif ($recipientID > 0) {                                                                                                                                                                                                                                                      
     174               0 :                 $this->db->query("INSERT INTO messaging_inbox (userID, authorID, subject, message, date)                                                                                                                                                                                       
     175               0 :                             VALUES ('".$recipientID."','".$this->userID."','".Data::toMysql($subject, false) ."','".Data::toMysql($message, false) ."',".time() .")");                                                                                                                         
     176               0 :                 if (isset($this->role)) RoleArtefacts::setRoleForItem(PM, $this->db->insert_id, $_SESSION["roleID"]);                                                                                                                                                                          
     177               0 :                 $outboxRecipients.= $recipientID.";";                                                                                                                                                                                                                                          
     178               0 :                 $recipientsSuccess.= $allRecipients[$i]." | ";                                                                                                                                                                                                                                 
     179               0 :                 $recipientIDs[] = $recipientID;                                                                                                                                                                                                                                                
     180               0 :             } else {                                                                                                                                                                                                                                                                           
     181               0 :                 $errorMessage = sprintf($this->translate->_("Benutzer %1\$s wurde nicht gefunden."), trim($allRecipients[$i]));                                                                                                                                                                
     182               0 :                 Output::errorMessage($errorMessage);                                                                                                                                                                                                                                           
     183               0 :                 $success = false;                                                                                                                                                                                                                                                              
     184               0 :                 $recipientsFailed.= "; ".trim($allRecipients[$i]);                                                                                                                                                                                                                             
     185                 :             }                                                                                                                                                                                                                                                                                  
     186               0 :         }                                                                                                                                                                                                                                                                                      
     187                 :         // Email an die Empfaenger senden, dass sie eine PN bekommen haben                                                                                                                                                                                                                     
     188               0 :         if ($asEmail && isset($recipientIDs)) {                                                                                                                                                                                                                                                
     189               0 :             global $settings;                                                                                                                                                                                                                                                                  
     190               0 :             $portalName = $settings["label"];                                                                                                                                                                                                                                                  
     191               0 :             $bbcode = new BBCode(false);                                                                                                                                                                                                                                                       
     192               0 :             $email = new Email($this->userID);                                                                                                                                                                                                                                                 
     193               0 :             $userName = $this->db->get_var("SELECT CONCAT(Vorname, ' ', Nachname) FROM user WHERE ID='".$this->userID."'");                                                                                                                                                                    
     194               0 :             $mailSubject = html_entity_decode($subject, ENT_COMPAT, $settings["charset"]) . " (" . $settings["label"].": Neue private Nachricht)";                                                                                                                                             
     195               0 :             $mailMessage = sprintf($this->translate->_("Guten Tag,\n %1\$s hat eine private Nachricht in %2\$s für Sie verfasst:\n\n--------------------\n%3\$s\n--------------------"), $userName, $portalName, html_entity_decode($bbcode->stripTags($message), ENT_COMPAT, "ISO-8859-15"));
     196                 :                                                                                                                                                                                                                                                                                                
     197               0 :             if ($email->sendMessageToUser($mailSubject, $recipientIDs, $mailMessage, false)) Output::echoMessage("Email zur Benachrichtigung versandt.");                                                                                                                                      
     198               0 :             else Output::errorMessage($this->translate->_("Email zur Benachrichtigung konnte nicht versandt werden."));                                                                                                                                                                        
     199               0 :         }                                                                                                                                                                                                                                                                                      
     200               0 :         if (!$asEmail && isset($recipientIDs)) {                                                                                                                                                                                                                                               
     201               0 :             global $settings;                                                                                                                                                                                                                                                                  
     202               0 :             $portalName = $settings["label"];                                                                                                                                                                                                                                                  
     203               0 :             $bbcode = new BBCode(false);                                                                                                                                                                                                                                                       
     204               0 :             $email = new Email($this->userID);                                                                                                                                                                                                                                                 
     205               0 :             $userName = $this->db->get_var("SELECT CONCAT(Vorname, ' ', Nachname) FROM user WHERE ID='".$this->userID."'");                                                                                                                                                                    
     206               0 :             $mailSubject = html_entity_decode($subject, ENT_COMPAT, $settings["charset"]) . " (" . $settings["label"].": Neue private Nachricht)";                                                                                                                                             
     207               0 :             $mailMessage = sprintf($this->translate->_("Guten Tag,\n %1\$s hat eine private Nachricht in %2\$s für Sie verfasst:\n\n--------------------\n%3\$s\n--------------------"), $userName, $portalName, html_entity_decode($bbcode->stripTags($message), ENT_COMPAT, "ISO-8859-15"));
     208                 :                                                                                                                                                                                                                                                                                                
     209               0 :             foreach ($recipientIDs as $recipient) {                                                                                                                                                                                                                                            
     210               0 :                 if ($this->pmAsEmail($recipient)) {                                                                                                                                                                                                                                            
     211               0 :                     $email->sendMessageToUser($mailSubject, array($recipient), $mailMessage, false);                                                                                                                                                                                           
     212               0 :                 }                                                                                                                                                                                                                                                                              
     213               0 :             }                                                                                                                                                                                                                                                                                  
     214               0 :         }                                                                                                                                                                                                                                                                                      
     215               0 :         if (strlen($outboxRecipients) > 0 && $saveInOutbox) {                                                                                                                                                                                                                                  
     216               0 :             $this->db->query("INSERT INTO messaging_outbox (userID, recipientID, subject, message, date)                                                                                                                                                                                       
     217               0 :                         VALUES ('".$this->userID."','".$outboxRecipients."','".Data::toMysql($subject, false) ."','".Data::toMysql($message, false) ."',".time() .")");                                                                                                                        
     218               0 :         }                                                                                                                                                                                                                                                                                      
     219               0 :         if (strlen($recipientsSuccess) > 0) {                                                                                                                                                                                                                                                  
     220               0 :             Output::echoMessage($this->translate->_("An folgende BenutzerInnen wurde die Nachricht gesendet:")." | ".Data::toHTML($recipientsSuccess));                                                                                                                                        
     221               0 :         }                                                                                                                                                                                                                                                                                      
     222               0 :         if (!$success) $recipients = substr($recipientsFailed, 2);                                                                                                                                                                                                                             
     223               0 :         return $success;                                                                                                                                                                                                                                                                       
     224                 :     }                                                                                                                                                                                                                                                                                          
     225                 :                                                                                                                                                                                                                                                                                                
     226                 :     /**                                                                                                                                                                                                                                                                                        
     227                 :      *                                                                                                                                                                                                                                                                                         
     228                 :      */                                                                                                                                                                                                                                                                                        
     229                 :     private function pmAsEmail( $userID ) {                                                                                                                                                                                                                                                    
     230               0 :         return $this->db->get_var("SELECT pm_as_email FROM user WHERE ID=$userID");                                                                                                                                                                                                            
     231                 :     }                                                                                                                                                                                                                                                                                          
     232                 :                                                                                                                                                                                                                                                                                                
     233                 :     /**                                                                                                                                                                                                                                                                                        
     234                 :      * Gibt die Anzahl der Benutzer zurück, die den gleich Vor- und Nachnamen haben wie der übergebene                                                                                                                                                                                       
     235                 :      *                                                                                                                                                                                                                                                                                         
     236                 :      * @access public                                                                                                                                                                                                                                                                          
     237                 :      * @param int $userID ID des Benutzers                                                                                                                                                                                                                                                     
     238                 :      * @return int Anzahl der Benutzer mit selbem Namen                                                                                                                                                                                                                                        
     239                 :      */                                                                                                                                                                                                                                                                                        
     240                 :     public function sameNameUsers($userID) {                                                                                                                                                                                                                                                   
     241               0 :         $countUsers = (int)$this->db->get_var("SELECT COUNT(*) FROM user u1, user u2 WHERE u1.Vorname=u2.Vorname AND u1.Nachname=u2.Nachname AND u1.ID<>u2.ID AND u1.ID='$userID'");                                                                                                           
     242               0 :         return $countUsers;                                                                                                                                                                                                                                                                    
     243                 :     }                                                                                                                                                                                                                                                                                          
     244                 :                                                                                                                                                                                                                                                                                                
     245                 :     /**                                                                                                                                                                                                                                                                                        
     246                 :      * Markiert eine Nachricht als gelesen                                                                                                                                                                                                                                                     
     247                 :      *                                                                                                                                                                                                                                                                                         
     248                 :      * @param integer $messageID, ID der Nachricht                                                                                                                                                                                                                                             
     249                 :      */                                                                                                                                                                                                                                                                                        
     250                 :     function markMessageAsRead($messageID) {                                                                                                                                                                                                                                                   
     251               0 :         $messageID = intval($messageID);                                                                                                                                                                                                                                                       
     252               0 :         $message = $this->db->get_row("SELECT * FROM messaging_inbox WHERE ID='$messageID' AND userID='".$this->userID."'");                                                                                                                                                                   
     253                 :                                                                                                                                                                                                                                                                                                
     254               0 :         if (!is_null($message) && $message->isRead == 0) {                                                                                                                                                                                                                                     
     255               0 :             $this->db->query("UPDATE messaging_inbox SET isRead='1' WHERE ID='$messageID' AND userID='".$this->userID."'");                                                                                                                                                                    
     256               0 :         }                                                                                                                                                                                                                                                                                      
     257               0 :     }                                                                                                                                                                                                                                                                                          
     258                 :                                                                                                                                                                                                                                                                                                
     259                 :     /**                                                                                                                                                                                                                                                                                        
     260                 :      * Loescht Nachricht.                                                                                                                                                                                                                                                                      
     261                 :      * @access public                                                                                                                                                                                                                                                                          
     262                 :      * @param integer $messageID ID, der zu loeschenden Nachricht                                                                                                                                                                                                                              
     263                 :      * @param string $type Bestimmt ob sich die Nachricht in der In- oder Outbox befindet                                                                                                                                                                                                      
     264                 :      * @return true falls erfolgreich, ansonsten false                                                                                                                                                                                                                                         
     265                 :      */                                                                                                                                                                                                                                                                                        
     266                 :     function deleteMessage($messageID, $type) {                                                                                                                                                                                                                                                
     267               0 :         $messageID = intval($messageID);                                                                                                                                                                                                                                                       
     268               0 :         if ($type == "inbox") {                                                                                                                                                                                                                                                                
     269               0 :             $this->db->query("DELETE FROM messaging_inbox WHERE ID='".$messageID."' AND userID='".$this->userID."'");                                                                                                                                                                          
     270               0 :             if ($this->db->rows_affected) RoleArtefacts::deleteItem(PM, (int)$messageID);                                                                                                                                                                                                      
     271               0 :         } elseif ($type == "outbox") {                                                                                                                                                                                                                                                         
     272               0 :             $this->db->query("DELETE FROM messaging_outbox WHERE ID='".$messageID."' AND userID=".$this->userID);                                                                                                                                                                              
     273               0 :         }                                                                                                                                                                                                                                                                                      
     274               0 :         if($this->db->num_rows > 0) {                                                                                                                                                                                                                                                          
     275               0 :             return true;                                                                                                                                                                                                                                                                       
     276                 :         }                                                                                                                                                                                                                                                                                      
     277                 :         else {                                                                                                                                                                                                                                                                                 
     278               0 :             return false;                                                                                                                                                                                                                                                                      
     279                 :         }                                                                                                                                                                                                                                                                                      
     280                 :     }                                                                                                                                                                                                                                                                                          
     281                 :                                                                                                                                                                                                                                                                                                
     282                 :     /**                                                                                                                                                                                                                                                                                        
     283                 :      * Setzt den Status der Nachricht auf archiviert.                                                                                                                                                                                                                                          
     284                 :      * @access public                                                                                                                                                                                                                                                                          
     285                 :      * @param integer $messageID ID, der zu archiverenden Nachricht                                                                                                                                                                                                                            
     286                 :      * @param string $type Bestimmt ob sich die Nachricht in der In- oder Outbox befindet                                                                                                                                                                                                      
     287                 :      * @return void                                                                                                                                                                                                                                                                            
     288                 :      */                                                                                                                                                                                                                                                                                        
     289                 :     public function archiveMessage($messageID, $type) {                                                                                                                                                                                                                                        
     290               0 :         $messageID = intval($messageID);                                                                                                                                                                                                                                                       
     291               0 :         if ($type == "inbox") $this->db->query("UPDATE messaging_inbox SET isArchived ='1' WHERE ID='".$messageID."' AND userID=".$this->userID);                                                                                                                                              
     292               0 :         elseif ($type == "outbox") $this->db->query("UPDATE messaging_outbox SET isArchived ='1' WHERE ID='".$messageID."' AND userID=".$this->userID);                                                                                                                                        
     293               0 :     }                                                                                                                                                                                                                                                                                          
     294                 :                                                                                                                                                                                                                                                                                                
     295                 :     /**                                                                                                                                                                                                                                                                                        
     296                 :      * Gibt die Empfaengerliste einer Nachricht zurueck                                                                                                                                                                                                                                        
     297                 :      * @access public                                                                                                                                                                                                                                                                          
     298                 :      * @param string $RecipientsID ID, der Empfaenger (ID1; ID2;...)                                                                                                                                                                                                                           
     299                 :      * @param integer $limit Gibt an wiviele Empfaenger in der Liste ausgegeben werden sollen.                                                                                                                                                                                                 
     300                 :      * @param integer $breaks Gibt an nach wievielen Namen ein <br> erfolgt                                                                                                                                                                                                                    
     301                 :      * @return void                                                                                                                                                                                                                                                                            
     302                 :      */                                                                                                                                                                                                                                                                                        
     303                 :     public function getRecipients($RecipientsID, $limit, $breaks) {                                                                                                                                                                                                                            
     304               0 :         $strWHERE = "";                                                                                                                                                                                                                                                                        
     305               0 :         $recipients = explode(";", $RecipientsID);                                                                                                                                                                                                                                             
     306               0 :         $count = count($recipients) -1;                                                                                                                                                                                                                                                        
     307               0 :         for ($i = 0 ; $i < $count && $i <= ($limit-1) ; $i++) {                                                                                                                                                                                                                                
     308               0 :             if ($strWHERE == "") $strWHERE = $strWHERE." user.ID =".$recipients[$i];                                                                                                                                                                                                           
     309               0 :             else $strWHERE = $strWHERE." OR user.ID =".$recipients[$i];                                                                                                                                                                                                                        
     310               0 :         }                                                                                                                                                                                                                                                                                      
     311               0 :         $empfaenger = $this->db->get_results("SELECT user.ID, user.Nachname, user.Vorname FROM user WHERE ".$strWHERE." ORDER BY user.Nachname");                                                                                                                                              
     312               0 :         $breakCount = 0;                                                                                                                                                                                                                                                                       
     313               0 :         $strEmpfaenger = "";                                                                                                                                                                                                                                                                   
     314               0 :         foreach($empfaenger as $einzelner) {                                                                                                                                                                                                                                                   
     315               0 :             $einzelner->Nachname = Data::toHTML($einzelner->Nachname, false);                                                                                                                                                                                                                  
     316               0 :             $einzelner->Vorname = Data::toHTML($einzelner->Vorname, false);                                                                                                                                                                                                                    
     317               0 :             if ($breakCount < $breaks) $strEmpfaenger.= "&lt;<a href='".PATH_TO_ROOT."user/homepage.php?user=".$einzelner->ID."'>".$einzelner->Nachname.", ".$einzelner->Vorname."</a>&gt; ";                                                                                                  
     318                 :             else {                                                                                                                                                                                                                                                                             
     319               0 :                 $strEmpfaenger.= "<br />&lt;<a href='".PATH_TO_ROOT."user/homepage.php?user=".$einzelner->ID."'>".$einzelner->Nachname.", ".$einzelner->Vorname."</a>&gt; ";                                                                                                                   
     320               0 :                 $breakCount = 0;                                                                                                                                                                                                                                                               
     321                 :             }                                                                                                                                                                                                                                                                                  
     322               0 :             $breakCount++;                                                                                                                                                                                                                                                                     
     323               0 :         }                                                                                                                                                                                                                                                                                      
     324               0 :         if ((count($recipients) -1) > $limit) $strEmpfaenger = $strEmpfaenger." ...";                                                                                                                                                                                                          
     325               0 :         return $strEmpfaenger;                                                                                                                                                                                                                                                                 
     326                 :     }                                                                                                                                                                                                                                                                                          
     327                 :     /**                                                                                                                                                                                                                                                                                        
     328                 :      * Gibt in der In- und Sentbox einen Header aus, der die Nachrichten sortieren laesst.                                                                                                                                                                                                     
     329                 :      * @access public                                                                                                                                                                                                                                                                          
     330                 :      * @param string $feld                                                                                                                                                                                                                                                                     
     331                 :      * @return String "auf" oder "ab"                                                                                                                                                                                                                                                          
     332                 :      */                                                                                                                                                                                                                                                                                        
     333                 :     public function getOrderByLink($feld) {                                                                                                                                                                                                                                                    
     334               0 :         if (isset($_GET["sortby"]) && $feld == $_GET["sortby"]) {                                                                                                                                                                                                                              
     335               0 :             if (isset($_GET["order"]) && $_GET["order"] == "ab") {                                                                                                                                                                                                                             
     336               0 :                 $orderlink = "auf";                                                                                                                                                                                                                                                            
     337               0 :             } else {                                                                                                                                                                                                                                                                           
     338               0 :                 $orderlink = "ab";                                                                                                                                                                                                                                                             
     339                 :             }                                                                                                                                                                                                                                                                                  
     340               0 :         } else {                                                                                                                                                                                                                                                                               
     341               0 :             $orderlink = "auf";                                                                                                                                                                                                                                                                
     342                 :         }                                                                                                                                                                                                                                                                                      
     343               0 :         return $orderlink;                                                                                                                                                                                                                                                                     
     344                 :     }                                                                                                                                                                                                                                                                                          
     345                 :                                                                                                                                                                                                                                                                                                
     346                 :     /**                                                                                                                                                                                                                                                                                        
     347                 :      * Liefert die UserID                                                                                                                                                                                                                                                                      
     348                 :      * @access public                                                                                                                                                                                                                                                                          
     349                 :      * @return integer UserID des aktuellen Benutzers                                                                                                                                                                                                                                          
     350                 :      */                                                                                                                                                                                                                                                                                        
     351                 :     public function getUserID() {                                                                                                                                                                                                                                                              
     352               0 :         if(!empty($this->userID)) {                                                                                                                                                                                                                                                            
     353               0 :             return $this->userID;                                                                                                                                                                                                                                                              
     354                 :         }                                                                                                                                                                                                                                                                                      
     355                 :         else                                                                                                                                                                                                                                                                                   
     356               0 :             return NULL;                                                                                                                                                                                                                                                                       
     357                 :     }                                                                                                                                                                                                                                                                                          
     358                 :                                                                                                                                                                                                                                                                                                
     359                 :     /**                                                                                                                                                                                                                                                                                        
     360                 :      * Liefert die Rolle des Benutzers                                                                                                                                                                                                                                                         
     361                 :      * @access public                                                                                                                                                                                                                                                                          
     362                 :      * @return Rolle des aktuellen Benutzers                                                                                                                                                                                                                                                   
     363                 :      */                                                                                                                                                                                                                                                                                        
     364                 :     public function getRole() {                                                                                                                                                                                                                                                                
     365               0 :         if(!empty($this->role)) {                                                                                                                                                                                                                                                              
     366               0 :             return $this->role;                                                                                                                                                                                                                                                                
     367                 :         }                                                                                                                                                                                                                                                                                      
     368                 :         else                                                                                                                                                                                                                                                                                   
     369               0 :             return NULL;                                                                                                                                                                                                                                                                       
     370                 :     }                                                                                                                                                                                                                                                                                          
     371                 :                                                                                                                                                                                                                                                                                                
     372                 :     /**                                                                                                                                                                                                                                                                                        
     373                 :      * Liefert das DB-Access Objekt                                                                                                                                                                                                                                                            
     374                 :      * @access public                                                                                                                                                                                                                                                                          
     375                 :      * @return DB-Access Objekt                                                                                                                                                                                                                                                                
     376                 :      */                                                                                                                                                                                                                                                                                        
     377                 :     public function getDB() {                                                                                                                                                                                                                                                                  
     378               0 :         if(!empty($this->db)) {                                                                                                                                                                                                                                                                
     379               0 :             return $this->db;                                                                                                                                                                                                                                                                  
     380                 :         }                                                                                                                                                                                                                                                                                      
     381                 :         else                                                                                                                                                                                                                                                                                   
     382               0 :             return NULL;                                                                                                                                                                                                                                                                       
     383                 :     }                                                                                                                                                                                                                                                                                          
     384                 :                                                                                                                                                                                                                                                                                                
     385                 :     /**                                                                                                                                                                                                                                                                                        
     386                 :      * Diese Klassenmethode fügt die CSS Datei in den eStudy Header ein.                                                                                                                                                                                                                      
     387                 :      * Der Aufruf muss vor den eStudy-Includes kommen!                                                                                                                                                                                                                                         
     388                 :      * @access public                                                                                                                                                                                                                                                                          
     389                 :      */                                                                                                                                                                                                                                                                                        
     390                 :     public static function includeMessagingCSSFile() {                                                                                                                                                                                                                                         
     391               0 :         global $HEADER_INLINE_AFTER_CSS;                                                                                                                                                                                                                                                       
     392               0 :         if(!isset($HEADER_INLINE_AFTER_CSS)) $HEADER_INLINE_AFTER_CSS = "";                                                                                                                                                                                                                    
     393               0 :         $HEADER_INLINE_AFTER_CSS .= '<link href="'.PATH_TO_ROOT.'messaging/messaging.css" rel="stylesheet" type="text/css" />';                                                                                                                                                                
     394               0 :     }                                                                                                                                                                                                                                                                                          
     395                 :                                                                                                                                                                                                                                                                                                
     396                 :     /**                                                                                                                                                                                                                                                                                        
     397                 :      * Liefert einen String, der den Include Code für das                                                                                                                                                                                                                                     
     398                 :      * AutoSearch und Autocompletion Javascript enthält                                                                                                                                                                                                                                       
     399                 :      * @access public                                                                                                                                                                                                                                                                          
     400                 :      *                                                                                                                                                                                                                                                                                         
     401                 :      * @return string String mit Javascript Include                                                                                                                                                                                                                                            
     402                 :      */                                                                                                                                                                                                                                                                                        
     403                 :     public static function getAutoSearchJavaScript() {                                                                                                                                                                                                                                         
     404               0 :         return '<script type="text/javascript" src="'.PATH_TO_ROOT.'messaging/js/messaging_autosearch.js"></script>';                                                                                                                                                                          
     405                 :     }                                                                                                                                                                                                                                                                                          
     406                 :                                                                                                                                                                                                                                                                                                
     407                 :     /**                                                                                                                                                                                                                                                                                        
     408                 :      * Setzt die globalen Variablen die im Modul benötigt werden.                                                                                                                                                                                                                             
     409                 :      * @access public                                                                                                                                                                                                                                                                          
     410                 :      */                                                                                                                                                                                                                                                                                        
     411                 :     public static function setGlobalVariables() {                                                                                                                                                                                                                                              
     412                 :         /** Zur Benutzung von SSL-Verschlüsselung vorsehen */                                                                                                                                                                                                                                 
     413               0 :         if ( ! defined("USE_SSL") ) define("USE_SSL", true);                                                                                                                                                                                                                                   
     414               0 :         define("PATH_TO_MESSAGE_NEW", "messaging_new.php");                                                                                                                                                                                                                                    
     415               0 :         define("PATH_TO_MESSAGE_IN", "messaging_in.php");                                                                                                                                                                                                                                      
     416               0 :         define("PATH_TO_MESSAGE_OUT", "messaging_out.php");                                                                                                                                                                                                                                    
     417               0 :         define("PATH_TO_MESSAGE_DETAIL", "messaging_detail.php");                                                                                                                                                                                                                              
     418               0 :         define("PATH_TO_BUDDYMANAGEMENT", "buddymanagement.php");                                                                                                                                                                                                                              
     419               0 :     }                                                                                                                                                                                                                                                                                          
     420                 : }                                                                                                                                                                                                                                                                                              

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.